package NovelBar.controller;

import NovelBar.entity.Goods;
import NovelBar.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/public")
public class GoodsController {
	@Autowired
	private GoodsService goodsService;
	
	@RequestMapping("/loadGoodsByBusiness")
	public List<Goods> loadGoodsByBusiness (String business) {
		return goodsService.loadGoodsByBusiness(business);
	}
	
	@RequestMapping("/loadAllGoods")
	public List<Goods> loadAllGoods () {
		return goodsService.loadAllGoods();
	} 
	
	@RequestMapping("/addGoods")
	public void addGoods(Goods goods) {
		goodsService.addGoods(goods);
	}
	
	@RequestMapping("/loadGoodsByRequire")
	public List<Goods> loadGoodsByRequire (String goodsNameRequire, String business, int priceMin, int priceMax) {
		return goodsService.loadGoodsByRequire(goodsNameRequire, business, priceMin, priceMax);
	}
}
